package com.wnxy.admin.common.config;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.nio.charset.Charset;

@Configuration
public class BloomFilterConfig {
    /**
     * 向Spring容器中 注册：布隆过滤器
     * @return
     */
    @Bean
    public BloomFilter<String> bloomFilter(){
        /*1000000L 表示：需要存放100W个KEY
         * 0.01 表示：误差率需要控制1%以内*/
        return BloomFilter.create(
                Funnels.stringFunnel(Charset.defaultCharset()),1000000L,0.01);
    }
}